$(function () {
    $("#shop1").click(function () {
        //添加class
        $("#shop1").addClass("active");
        $("#shop2").removeClass("active");
        $("#list1").css("display", "block");
        $("#list2").css("display", "none");
        //ajax请求后台
        $.ajax({
            url: "/petIndex/shopDaoHang",
            type: "post",
            data: "",
            dataType: "json",
            success: function (data) {
                //清空子元素
                $("#list11").empty();
                $.each(data, function (i, info) {
                    $("#list11").append("<li ><a><span class='proType'>" + info.proType + "</span></a> <a class='more' href='index.html'>更多</a></li>");
                })
            }
        });
    })

    $("#shop2").click(function () {
        //添加class
        $("#shop2").addClass("active");
        $("#shop1").removeClass("active");
        $("#list2").css("display", "block");
        $("#list1").css("display", "none");

        //ajax请求后台
        $.ajax({
            url: "/petIndex/discountPro",
            type: "post",
            data: "",
            dataType: "json",
            success: function (data) {
                //清空子元素
                $("#list22").empty();
                $.each(data, function (i, pet) {
                    $("#list22").append("<li ><a><span class='propName'>" + pet.proName + "</span></a> <a class='more' href='index.html'>更多</a></li>");
                })
            }
        });
    })
});

//查询对应的商品跳转
$(function () {
    //绑定点击事件
    $(document).on("click",".proType",function () {
        var proType = $(this).text();
        window.location.href="/petIndex/jumpToPro?proType="+proType;
    })
});

$(function () {
    //绑定点击事件
    $(document).on("click",".propName",function () {
        var proName = $(this).text();
        window.location.href="/petIndex/jumpToPro1?proName="+proName;
    })
})

